﻿using System;
using System.Collections.Generic;

namespace UnitTestDemo.SimpleDemo
{
    public class Person
    {
        #region Fields
        private readonly List<ContactInfo> contacts;

        private string name;
        private Gender gender;
        private int age;
        private int energy;
        #endregion

        public Person(string name)
        {
            if (string.IsNullOrEmpty(name)) { throw new ArgumentException("name"); }

            this.name = name;
            this.energy = 100;
            this.contacts = new List<ContactInfo>();
        }

        #region Properties
        public string Name 
        {
            get { return this.name; }
            set { this.name = value; }
        }

        public Gender Gender
        {
            get { return this.gender; }
            set { this.gender = value; }
        }

        public int Age
        {
            get { return this.age; }
            set { this.age = value; }
        }

        public List<ContactInfo> Contacts
        { 
            get { return this.contacts; } 
        }

        public int Energy
        {
            get { return this.energy; }
        }
        #endregion

        #region Methods

        #region Public Methods

        public void Run()
        {
            const int cost = 50;

            if (this.energy < cost) { throw new NotSupportedException(); }

            this.energy -= cost;
        }

        public void Sleep()
        {
            this.energy = 100;
        }

        public void Eat()
        {
            const int cost = 30;

            if (this.energy < cost) { throw new NotSupportedException(); }

            this.energy -= cost;
        }

        #endregion

        #endregion
    }
}
